package com.xiejr.actuator.socket.config;

import com.xiejr.actuator.init.abstracts.AbstractGlobalApplicationInit;
import com.xiejr.actuator.socket.Topic;
import com.xiejr.actuator.socket.abstracts.TopicWebsocketHelper;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @program: socket-actuator-spring-boot-starter
 * @description: 主题观察者配置
 * @author: xjr
 * @create: 2020-07-13 14:50
 **/
@Component
public class TopicObserverConfiguration extends AbstractGlobalApplicationInit {
    @Override
    public void execute(ApplicationContext applicationContext, Environment environment, String beanName) throws Throwable {
        Map<String,Topic> topicMap=applicationContext.getBeansOfType(Topic.class);
        TopicWebsocketHelper.setHandlers(topicMap);
    }

    @Override
    public int order() {
        return 1;
    }
}
